﻿using System.Collections.Generic;
using Mono.Cecil;
using OpenReflect.Domain.Contracts;

namespace OpenReflect.Services.Builders
{
	public interface INamespaceBuilder
	{
		IClassBuilder ClassBuilder { get; }

		IInterfaceBuilder InterfaceBuilder { get; }
		INamespace CreateNamespace();
		IList<INamespace> CreateNamespaces(ModuleDefinition module);
	}

	public class NamespaceBuilder : INamespaceBuilder
	{
		public NamespaceBuilder(IClassBuilder classBuilder, IInterfaceBuilder interfaceBuilder)
		{
			ClassBuilder = classBuilder;
			InterfaceBuilder = interfaceBuilder;
		}

		#region INamespaceBuilder Members

		public INamespace CreateNamespace()
		{
			return null;
		}


		public IList<INamespace> CreateNamespaces(ModuleDefinition module)
		{
			IList<INamespace> retVal = new List<INamespace>();
			//String
			//IEnumerable<int> a;
			//a.ToArray<string>();
			foreach (TypeDefinition type in module.Types)
			{
				IList<IClass> classes = ClassBuilder.CreateClasses(type);
				//ControlFlowGraph g = FlowGraphFactory.CreateControlFlowGraph()
				//type.Methods[0].Body.

				//if (retVal.Contains()
				//{

				//}
			}

			return retVal;
		}

		public IClassBuilder ClassBuilder { get; private set; }

		public IInterfaceBuilder InterfaceBuilder { get; private set; }

		#endregion
	}
}